package edu.pku.sei.transformation.editor.model.execution;

import org.w3c.dom.Element;

import edu.pku.sei.gefcommon.descriptor.annotation.MethodProperty;
import edu.pku.sei.modeler.model.xml.XMLUtility;
import edu.pku.sei.transformation.editor.model.ModelPackage;

public class DecisionNode extends ControlNode {
	private String expression;
	
	private DecisionNode(int type) {
		super(type);
	}
	
	public DecisionNode() {
		super(CONTROL_DECISION);
	}
	
	/**
	 * @return
	 */
	@MethodProperty(id = ModelPackage.DICISIONNODE_EXPRESSION, name="expression", setter = "setExpression", catalog="decision node")
	public String getExpression() {
		return expression;
	}
	
	public void setExpression(String exp) {
		this.expression = exp;
		this.firePropertyChange(ModelPackage.DICISIONNODE_EXPRESSION, null, null);
	}
	
	@Override
	public void serialize(Element root) {
		super.serialize(root);
		XMLUtility.xmlInstance.serializeAttribute(root, ModelPackage.DICISIONNODE_EXPRESSION, expression);
	}
	
	@Override
	public void deSerialize(Element root) {
		super.deSerialize(root);
		this.expression = XMLUtility.xmlInstance.deSerializeString(root, ModelPackage.DICISIONNODE_EXPRESSION);
	}

}
